/*
ID:luongho3
LANG:JAVA
TASK:ride
 */
package usaco.training.chap1.sec1;

import java.io.File;
import java.io.PrintStream;
import java.util.Scanner;

public class ride {

	static String a,b;
	static int MOD = 47;
	static int ia, ib;
	
	public static void main(String[] args) throws Exception {
		Scanner scanner = new Scanner(new File("ride.in"));
		PrintStream ps = new PrintStream(new File("ride.out"));
		System.setOut(ps);
		a = scanner.next();
		b = scanner.next();
		
		ia = valOf(a);
		ib = valOf(b);
		
		if (ia == ib) {
			System.out.println("GO");
		}
		else {
			System.out.println("STAY");
		}

	}

	private static int valOf(String s) {
		int len = s.length();
		int prod = 1;
		for (int i=0;i<len;++i) {
			int val = s.charAt(i) - 'A' + 1;
			prod *= val;
			prod %= MOD;
		}
		return prod;
	}

}
